package com.wonders.frame.entity;


import com.wonders.frame.core.entity.EntityTemplate;
import lombok.Data;

import javax.persistence.*;
import java.util.List;

@Entity
@Data
@Table(name = "auth_dic_type")
public class AuthDicType extends EntityTemplate {

    @Column(name = "code")
    private String code; //代码，

    @Column(name = "description")
    private String description;         //'描述',

    @Column(name = "displaytype")
    private String displaytype;          //'展示类型(普通，树)',

    @Column(name = "simplename")
    private String simplename;        //'简称',

    @Column(name = "seq")
    private Integer seq;                  //'序号',

    @Column(name = "parent_id")
    private String parentId;           //'父节点',关联字典类型表的code

    @Transient
    @ManyToOne(cascade = {CascadeType.REFRESH})
    @JoinColumn(name = "parent_id")
    private AuthDicType parent;        // 多对一

    @OneToMany(cascade = {CascadeType.REFRESH, CascadeType.REMOVE}, fetch = FetchType.EAGER)
    @JoinColumn(name = "parent_id")
    private List<AuthDicType> authDicTypeChildren; //  一对多


    @Column(name = "name")
    private String name;                 //'名称', 即字典对应值。

    @Column(name = "dic_type")
    private String dicType;             //'关联字典类型表的code'

}